package kumi.kumi.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by Administrator on 2016/8/6 0006.
 */
public class getConnection {
    public static Connection getConnection(){
        //jdbc 是数据库的名字
        String url = "jdbc:mysql://localhost:3306/mybooks";
        Connection connection = null;
        String username = "root";
        String password = "root";

        try {
            //其实新建了这个类
            Class.forName("com.mysql.jdbc.Driver");
            connection =
                    DriverManager.getConnection(url,username,password);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return connection;
    }
}
